package com.saver.modules.sys.dao;

import com.saver.modules.sys.entity.SysRoleMenuEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.Set;

public interface SysRoleMenuDao extends JpaRepository<SysRoleMenuEntity, Integer> {

    @Transactional
    void deleteAllByRoleId(Long roleId);

    @Transactional
    void deleteAllByMenuId(Long menuId);

    @Query(value = "select menu_id from sys_role_menu where role_id=?1",nativeQuery = true)
    Set<Long> findByRoleId(Long roleId);

    @Query(value = "select menu_id from sys_role_menu",nativeQuery = true)
    Set<Long> findAllMenuId();
}
